<template>
  <div class="bi-select">
    <span class="select-titls">{{ props.selectName }}</span>
    <div class="select-view" v-if="props.selectList.length > 0">
      <div
        class="select-li"
        v-for="(item, index) in props.selectList"
        :key="index"
        @click="onSelectClick(item)"
      >
        <i v-if="item.icon" :class="['iconfont', item.icon]"></i>
        <span>{{ item[props.selectKey || "label"] }}</span>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref } from "vue";
const props = defineProps({
  selectList: {
    type: Array,
    default: () => {
      return [];
    },
  },
  selectName: {
    type: String,
    default: "标题",
  },
  selectKey: {
    type: String,
  },
});
const values = ref("");
const emit = defineEmits(['handelSelect']);
const onSelectClick = (item) => {
  emit("handelSelect", item);
};
</script>
<style lang="scss" scoped>
.bi-select {
  display: flex;
  max-height: 6rem;
  flex-direction: column;
  .select-titls {
    height: 0.3rem;
    /* font-size: 0.16rem; */
    font-weight: 700;
  }
  .select-view {
    max-height: 4.5rem;
    .select-li {
      height: 0.28rem;
      line-height: 0.28rem;
      box-sizing: border-box;
      padding: 0 0.05rem;
      border-radius: 0.02rem;
      &:hover {
        background: #f2f3f5;
        cursor: pointer;
      }
    }
  }
}
</style>